package com.design;

import java.util.HashMap;
import java.util.Map;

/**
 * 享元工厂
 */
public class ProductFactory {
    private static final Map<String, Product> products = new HashMap<>();

    public static Product getProduct(String id) {
        Product product = products.get(id);
        if (product == null) {
            product = new Product(id,"可乐","可口可乐","快乐肥仔水");
            products.put(id, product);
        }
        return product;
    }
}
